<?php
namespace Api\Behaviors;

class LoginRecordBehavior extends \Think\Behavior{
    
    public function run(&$user){
        $latestLoginTime = time();
        $latestLoginIp = get_client_ip();
        $user['latest_login_time'] = $latestLoginTime;
        $user['latest_login_ip'] = $latestLoginIp;
        
        D('Users')->where(['id' => $user['id']])->setField([
            'latest_login_time' => $latestLoginTime,
            'latest_login_ip' => $latestLoginIp,
        ]);
    }
}
